// 权限控制// 导入路由守卫
import router from './router'
// Vuex中拿token
import store from './store'
// 白名单
const WHITE_LIST = ['/login']
// 前置路由守卫
router.beforeEach((to, from, next) => {
  const token = store.state.user.token
  if (token) {
    next()
  } else {
    if (WHITE_LIST.includes(to.path)) {
      next()
    } else {
      next('/login')
    }
  }
})
